<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="button" value="参数" id="ip">
  <script src="./cs.js"></script>
  <script>
    var ins = document.getElementById("ip");
    function addEvent(ele,type,fun) {
      if (ele.addEventListener) {
        ele.addEventListener(type,fun)
      }else if (ele.addachEvent) {
        ele.addEvent("on"+type,fun)
      }
    }
    // // 移除事件的兼容写法
    // // 参数：事件源，事件类型，事件函数
    function removeEvent(ele,type,fun) {
      if (ele.removeEventListener) {
        ele.removeEventListener(type,fun)
      }else if (ele.detachEvent) {
        ele.detachEvent("on"+type,fun)
      }
    }

    function fun1() {
      alert(1)
    }
    addEvent(ins,"click",fun1)
    addEvent(ins,"click",function () {
      alert(2)
    })



    removeEvent(ins,"click",fun1)
    // 匿名函数咋填
    removeEvent(ins,"click",function () {
      alert(2)
    })

  </script>
</body>
</html>